package com.haizhi.thread;

import com.haizhi.exit.StopEnable;
import com.haizhi.factory.MongodbFactory;
import com.haizhi.factory.RedisFactory;
import com.haizhi.redis.RedisHandler;
import com.mongodb.client.MongoDatabase;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: youfeng
 * Date: 2018-06-25
 * Time: 18:01
 */
public class TaskThread extends Thread implements StopEnable {

    private boolean running = true;

    //mongodb句柄
    protected MongoDatabase mongoDatabase;

    /**
     * redis 句柄
     */
    protected RedisHandler redisHandler;

    public TaskThread() throws Exception {
        //初始化MongoDB
        mongoDatabase = MongodbFactory.get("mongo.properties");

        //初始化redis
        redisHandler = RedisFactory.get("redis.properties");
    }

    @Override
    public void run() {
    }

    //获得运行状态
    public boolean isRunning() {
        return running;
    }

    @Override
    public void shutdown() {
        running = false;
    }
}
